package com.alan.http;

import java.util.HashMap;

public class HttpParameter {

    private HashMap<String, String> map;

    private boolean encoding = true;

    private String url;

    public HashMap<String, String> getMap() {
        return map;
    }

    public boolean isEncoding() {
        return encoding;
    }

    public String getUrl() {
        return url;
    }

    public static HttpParameterBuilder builder() {
        return new HttpParameterBuilder();
    }

    public static class HttpParameterBuilder {

        private HashMap<String, String> map;
        private boolean encoding = true;

        private String url;

        public HttpParameterBuilder() {
            map = new HashMap<>();
            encoding = true;
        }

        public HttpParameterBuilder add(String key, String value) {
            map.put(key, value);
            return this;
        }

        public HttpParameterBuilder add(String key, int value) {
            map.put(key, String.valueOf(value));
            return this;
        }

        public HttpParameterBuilder add(String key, boolean value) {
            map.put(key, String.valueOf(value));
            return this;
        }

        public HttpParameterBuilder add(String key, long value) {
            map.put(key, String.valueOf(value));
            return this;
        }

        public HttpParameterBuilder setEncoding(boolean encoding) {
            this.encoding = encoding;
            return this;
        }

        public HttpParameterBuilder setUrl(String url) {
            this.url = url;
            return this;
        }

        public HttpParameterBuilder setMap(HashMap<String, String> map) {
            this.map = map;
            return this;
        }

        public HttpParameter build() {
            HttpParameter parameter = new HttpParameter();
            parameter.map = map;
            parameter.url = url;
            parameter.encoding = encoding;
            return parameter;
        }
    }

}
